package com.ufsoft.report.toolbar.dropdown;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;

import javax.swing.UIManager;

public class ColorPanel extends SwatchPanel{
  
   public ColorPanel(){
	   super(false);
	   super.init();
   }
   @Override
	public void initLayout() {
	   swatchSize = UIManager.getDimension("ColorChooser.swatchesSwatchSize");
       numSwatches = new Dimension(31, 9);
		
	}

	@Override
	public void initValues() {
		int ai[] = initRawValues();
	       int i = ai.length / 3;
	       swatchs = new Color[i];
	       swatchValues=new Integer[i];
	       for(int j = 0; j < i; j++){
	    	   swatchs[j] = new Color(ai[j * 3], ai[j * 3 + 1], ai[j * 3 + 2]);
	    	   swatchValues[j]=new Integer(((Color)swatchs[j]).getRGB());
	       }
		
	}
	@Override
	/**
	 * 
	 */
   public String getToolTipText(MouseEvent mouseevent)
   {
       Color color =null;
       Object o=getSwatchForLocation(mouseevent.getX(), mouseevent.getY());
       if(o instanceof Color){
    	   color= (Color)o;
       }
        if(color==null)
        	return "";
       return (new StringBuilder()).append(color.getRed()).append(", ").append(color.getGreen()).append(", ").append(color.getBlue()).toString();
   }
   
   private int[] initRawValues()
   {
       int ai[] = {
           255, 255, 255, 204, 255, 255, 204, 204, 255, 204, 
           204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 
           255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 
           204, 204, 255, 255, 204, 255, 255, 204, 204, 255, 
           204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 
           204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 
           255, 204, 204, 255, 255, 204, 204, 255, 204, 204, 
           255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 
           204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 
           204, 255, 204, 204, 204, 204, 153, 255, 255, 153, 
           204, 255, 153, 153, 255, 153, 153, 255, 153, 153, 
           255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 
           153, 153, 255, 204, 153, 255, 255, 153, 255, 255, 
           153, 204, 255, 153, 153, 255, 153, 153, 255, 153, 
           153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 
           255, 153, 153, 255, 204, 153, 255, 255, 153, 204, 
           255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 
           153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 
           153, 255, 153, 153, 255, 204, 204, 204, 204, 102, 
           255, 255, 102, 204, 255, 102, 153, 255, 102, 102, 
           255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 
           102, 102, 255, 153, 102, 255, 204, 102, 255, 255, 
           102, 255, 255, 102, 204, 255, 102, 153, 255, 102, 
           102, 255, 102, 102, 255, 102, 102, 255, 102, 102, 
           255, 102, 102, 255, 153, 102, 255, 204, 102, 255, 
           255, 102, 204, 255, 102, 153, 255, 102, 102, 255, 
           102, 102, 255, 102, 102, 255, 102, 102, 255, 102, 
           102, 255, 102, 102, 255, 153, 102, 255, 204, 153, 
           153, 153, 51, 255, 255, 51, 204, 255, 51, 153, 
           255, 51, 102, 255, 51, 51, 255, 51, 51, 255, 
           51, 51, 255, 102, 51, 255, 153, 51, 255, 204, 
           51, 255, 255, 51, 255, 255, 51, 204, 255, 51, 
           153, 255, 51, 102, 255, 51, 51, 255, 51, 51, 
           255, 51, 51, 255, 102, 51, 255, 153, 51, 255, 
           204, 51, 255, 255, 51, 204, 255, 51, 153, 244, 
           51, 102, 255, 51, 51, 255, 51, 51, 255, 51, 
           51, 255, 51, 51, 255, 102, 51, 255, 153, 51, 
           255, 204, 153, 153, 153, 0, 255, 255, 0, 204, 
           255, 0, 153, 255, 0, 102, 255, 0, 51, 255, 
           0, 0, 255, 51, 0, 255, 102, 0, 255, 153, 
           0, 255, 204, 0, 255, 255, 0, 255, 255, 0, 
           204, 255, 0, 153, 255, 0, 102, 255, 0, 51, 
           255, 0, 0, 255, 51, 0, 255, 102, 0, 255, 
           153, 0, 255, 204, 0, 255, 255, 0, 204, 255, 
           0, 153, 255, 0, 102, 255, 0, 51, 255, 0, 
           0, 255, 0, 0, 255, 51, 0, 255, 102, 0, 
           255, 153, 0, 255, 204, 102, 102, 102, 0, 204, 
           204, 0, 204, 204, 0, 153, 204, 0, 102, 204, 
           0, 51, 204, 0, 0, 204, 51, 0, 204, 102, 
           0, 204, 153, 0, 204, 204, 0, 204, 204, 0, 
           204, 204, 0, 204, 204, 0, 153, 204, 0, 102, 
           204, 0, 51, 204, 0, 0, 204, 51, 0, 204, 
           102, 0, 204, 153, 0, 204, 204, 0, 204, 204, 
           0, 204, 204, 0, 153, 204, 0, 102, 204, 0, 
           51, 204, 0, 0, 204, 0, 0, 204, 51, 0, 
           204, 102, 0, 204, 153, 0, 204, 204, 102, 102, 
           102, 0, 153, 153, 0, 153, 153, 0, 153, 153, 
           0, 102, 153, 0, 51, 153, 0, 0, 153, 51, 
           0, 153, 102, 0, 153, 153, 0, 153, 153, 0, 
           153, 153, 0, 153, 153, 0, 153, 153, 0, 153, 
           153, 0, 102, 153, 0, 51, 153, 0, 0, 153, 
           51, 0, 153, 102, 0, 153, 153, 0, 153, 153, 
           0, 153, 153, 0, 153, 153, 0, 153, 153, 0, 
           102, 153, 0, 51, 153, 0, 0, 153, 0, 0, 
           153, 51, 0, 153, 102, 0, 153, 153, 0, 153, 
           153, 51, 51, 51, 0, 102, 102, 0, 102, 102, 
           0, 102, 102, 0, 102, 102, 0, 51, 102, 0, 
           0, 102, 51, 0, 102, 102, 0, 102, 102, 0, 
           102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 
           102, 0, 102, 102, 0, 102, 102, 0, 51, 102, 
           0, 0, 102, 51, 0, 102, 102, 0, 102, 102, 
           0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 
           102, 102, 0, 102, 102, 0, 51, 102, 0, 0, 
           102, 0, 0, 102, 51, 0, 102, 102, 0, 102, 
           102, 0, 102, 102, 0, 0, 0, 0, 51, 51, 
           0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 
           51, 51, 0, 0, 51, 51, 0, 51, 51, 0, 
           51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 
           51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 
           0, 51, 51, 0, 0, 51, 51, 0, 51, 51, 
           0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 
           51, 51, 0, 51, 51, 0, 51, 51, 0, 0, 
           51, 0, 0, 51, 51, 0, 51, 51, 0, 51, 
           51, 0, 51, 51, 51, 51, 51
       };
       return ai;
   }
}
